home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / mui / mui-tools / multiuser / src / support / kill_freeze_unfreeze.c < prev    next >
C/C++ Source or Header  |  1995-03-09  |  2KB  |  105 lines

  1. /************************************************************
  2. * MultiUser - MultiUser Task/File Support System                *
  3. * ---------------------------------------------------------    *
  4. * Kill/Freeze/UnFreeze                                                    *
  5. * ---------------------------------------------------------    *
  6. * © Copyright 1993-1994 Geert Uytterhoeven                        *
  7. * All Rights Reserved.                                                    *
  8. ************************************************************/
  9.  
  10.  
  11. #include <exec/types.h>
  12. #include <dos/dos.h>
  13. #include <proto/exec.h>
  14. #include <proto/dos.h>
  15. #include <libraries/multiuser.h>
  16. #include <proto/multiuser.h>
  17. #include <string.h>
  18.  
  19. #ifdef _MU_KILL_
  20. #include "Kill_rev.h"
  21. #endif
  22. #ifdef _MU_FREEZE_
  23. #include "Freeze_rev.h"
  24. #endif
  25. #ifdef _MU_UNFREEZE_
  26. #include "Unfreeze_rev.h"
  27. #endif
  28.  
  29. #include "Locale.h"
  30.  
  31. char __VersTag__[] = VERSTAG;
  32.  
  33.  
  34. int a2num(char *str);
  35.  
  36.  
  37. int __saveds Start(char *arg)
  38. {
  39.     struct ExecBase *SysBase;
  40.     struct DosLibrary *DOSBase;
  41.     struct muBase *muBase = NULL;
  42.     struct RDArgs *rdargs;
  43.     LONG args[] = {
  44. #define argTCB        0
  45.         NULL
  46.     };
  47.     struct Task *task;
  48.     int rc = RETURN_ERROR;
  49.  
  50.     SysBase = *(struct ExecBase **)4;
  51.  
  52.     if ((!(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 37))) ||
  53.          (!(muBase = (struct muBase *)OpenLibrary("multiuser.library", 39)))) {
  54.         rc = ERROR_INVALID_RESIDENT_LIBRARY;
  55.         goto Exit;
  56.     }
  57.     if (!(rdargs = ReadArgs("TCB/A", args, NULL)))
  58.         PrintFault(IoErr(), NULL);
  59.     else if (!(task = (struct Task *)a2num((char *)args[argTCB])))
  60.         PutStr(GetLocStr(MSG_BADARG));
  61. #ifdef _MU_KILL_
  62.     else if (!muKill(task))
  63.         PutStr(GetLocStr(MSG_KILLFAIL));
  64. #endif
  65. #ifdef _MU_FREEZE_
  66.     else if (!muFreeze(task))
  67.         PutStr(GetLocStr(MSG_FREEZEFAIL));
  68. #endif
  69. #ifdef _MU_UNFREEZE_
  70.     else if (!muUnfreeze(task))
  71.         PutStr(GetLocStr(MSG_UNFREEZEFAIL));
  72. #endif
  73.     else
  74.         rc = RETURN_OK;
  75.     FreeArgs(rdargs);
  76.  
  77. Exit:
  78.     CloseLibrary((struct Library *)muBase);
  79.     CloseLibrary((struct Library *)DOSBase);
  80.  
  81.     return(rc);
  82. }
  83.  
  84.  
  85. int a2num(char *str)
  86. {
  87.     BOOL hex = FALSE;    
  88.     int val = 0;
  89.  
  90.     if (str[0] == '$') {
  91.         hex = 1;
  92.         str++;
  93.     } else if ((str[0] == '0') && ((str[1] == 'x') || (str[1] == 'X'))) {
  94.         hex = 1;
  95.         str += 2;
  96.     }
  97.     if (hex) {
  98.         if (stch_i(str, &val) != strlen(str))
  99.             val = 0;
  100.     } else
  101.         if (stcd_i(str, &val) != strlen(str))
  102.             val = 0;
  103.     return(val);
  104. }
  105.